package com.lt.flashcard.model.entity;

import java.util.ArrayList;
import java.util.List;

/**
 * The class represent the result after an action
 * @author ocsen
 *
 */
public class ActionResult {

	private boolean error = true;
	private List<String> messages;
	private List<Object> objects;
	
	public boolean isError() {
		return error;
	}
	
	public void setError(boolean error) {
		this.error = error;
	}
	
	public List<String> getMesages() {
		return messages;
	}
	
	public String getMessage() {
		return messages != null && messages.size() > 0 ? messages.get(0) : null;
	}
	
	public void setMesages(List<String> mesages) {
		this.messages = mesages;
	}
	
	public void addMessage(String message) {
		if(this.messages == null) {
			this.messages = new ArrayList<String>();
		}
		this.messages.add(message);
	}
	
	public List<Object> getObjects() {
		return objects;
	}
	
	public Object getObject() {
		return objects != null && objects.size() > 0 ? objects.get(0) : null;
	}
	
	public void setObjects(List<Object> objects) {
		this.objects = objects;
	}
	
	public void addObject(Object object) {
		if(this.objects == null)
			this.objects = new ArrayList<Object>();
		this.objects.add(object);
	}
}
